﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;

namespace WindowsCountdownShutdownSoftware.Util
{
    public class ToggleButtonStyleConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            // 获取当前资源字典中的样式
            var resources = Application.Current.Resources;

            if (value is bool isUploading)
            {
                if (isUploading)
                {
                    return resources["ToggleButtonLoadingWarning"] as Style;
                }
                else
                {
                    return resources["ToggleButtonLoadingPrimary"] as Style;
                }
            }

            return resources["ToggleButtonLoadingPrimary"] as Style; // 默认
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException("双向转换不支持");
        }
    }
}
